Shader "Unlit/01"
{
    Properties
    {
        _Color ("Color", Color) = (1,1,1,1)

    }
    SubShader
    {
        Tags
        {
            "RenderType"="Opaque"
        }
        LOD 100

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

            fixed4 _Color;
            float _EllipseRadiusX; // This will be the semi-major axis (a)
            float _EllipseRadiusY; // This will be the semi-minor axis (b)

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 vertex : SV_POSITION;
                float2 position : TEXCOORD1; // Store the vertex position in screen space
            };

            v2f vert(appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = v.uv;
                o.position = v.vertex.xy; // Pass the local position to the fragment shader
                return o;
            }

            fixed4 frag(v2f i) : SV_Target
            {
                // Normalize the position to be relative to the center of the ellipse
                float2 centeredPos = i.position.xy;

                // Calculate the ellipse equation: (x^2 / a^2) + (y^2 / b^2) = 1
                float inEllipse = 1 - step(1, dot(centeredPos / float2(_EllipseRadiusX, _EllipseRadiusY),
                                                  centeredPos / float2(_EllipseRadiusX, _EllipseRadiusY)));

                // Use the clip function to discard fragments outside the ellipse
                clip(-(inEllipse - 0.1));

                // Return the color for fragments inside the ellipse
                return fixed4(_Color.rgb, 1);
            }
            ENDCG
        }
    }
    FallBack "Diffuse"
}